package spark.graphics.scenegraph;

import spark.math.Vector3;
import spark.math.Matrix;
import spark.math.Vector2;
import spark.graphics.Renderer;

public class TransformationNodeZRotation extends SceneGraphNode{
	private Vector3 translation;
	private Float rotationZ;
	private Vector3 scale;

	public TransformationNodeZRotation(Float rotationZangle) {
		this.rotationZ = rotationZangle;
	}

	public TransformationNodeZRotation(Vector3 translation, Float rotationZangle, Vector3 scale) {
		this.translation = translation;
		this.rotationZ = rotationZangle;
		this.scale = scale;
	}

	public TransformationNodeZRotation(Vector2 translation, Float rotationZangle, Vector3 scale) {
		this.translation = new Vector3();
		this.translation.copy(translation);
		this.rotationZ = rotationZangle;
		this.scale = scale;
	}

	@Override
	public void prepare() {
		Renderer.getInstance().getGl().glPushMatrix();
		if(translation != null) {
			Renderer.getInstance().getGl().glTranslatef(translation.x, translation.y, translation.z);
		}
		if(rotationZ != null) {
			Renderer.getInstance().getGl().glRotatef(rotationZ, 0, 0, 1);
		}
		if(scale != null) {
			Renderer.getInstance().getGl().glScalef(scale.x, scale.y, scale.z);
		}
	}

	@Override
	protected void cleanup() {
		Renderer.getInstance().getGl().glPopMatrix();
	}
}